class WestTextEvent {
    private static instance: WestTextEvent

    public static ins(): WestTextEvent {
        if (!this.instance) {
            this.instance = new WestTextEvent();
        }
        return this.instance;
    }

    doEvent(event: string, args: string[]): void {
        const func = this.events[event];
        if (!func) {
            console.error('not find textEvent', event);
            return;
        }
        func(...args);
    }

    events: {[key: string]: (...args:string[])=>void} = {}

    registTextEvent(event: string, func: (...args:string[])=>void): void {
        this.events[event] = func;
    }

    onTextEvent(sevent: string): void {
        const sp = sevent.split(' ');
        const event = sp.shift();
        this.doEvent(event, sp);
    }

    onImageEvent(event: string, param: string): void {
        const func = this.events[event];
        if (!func) {
            console.error('not find imageEvent', event);
            return;
        }
        func(param);
    }
}
